package com.bike.bikeserver.controller.frontend;

import com.bike.bikeserver.common.annotation.OperationLog;
import com.bike.bikeserver.common.core.domain.CommonResult;
import com.bike.bikeserver.domain.vo.BikeDispatchHandleVo;
import com.bike.bikeserver.service.IBikeDispatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0
 * @Author ZZX
 * @Date 2023/7/10 15:27
 */
@RestController
@RequestMapping("front/bikeDispatch")
public class BikeDispatchController
{
    @Autowired
    IBikeDispatchService bikeDispatchService;

    /**
     * 获取所有未处理的单车调度信息
     *
     * @return
     */
    @OperationLog(value = "获取所有未处理的单车调度信息:bike_dispatch")
    @GetMapping("getUnhandledBikeDispatches")
    public CommonResult getUnhandledBikeDispatches()
    {
        return bikeDispatchService.getUnhandledBikeDispatches();
    }

    /**
     * 根据id接受调度
     *
     * @param bikeDispatchHandleVo
     * @return
     */
    @OperationLog(value = "根据id接受调度:bike_dispatch")
    @PutMapping("acceptDispatchById")
    public CommonResult acceptDispatchById(@RequestBody BikeDispatchHandleVo bikeDispatchHandleVo)
    {
        return bikeDispatchService.acceptDispatchById(bikeDispatchHandleVo);
    }

    /**
     * 根据id拒绝调度
     *
     * @param bikeDispatchHandleVo
     * @return
     */
    @OperationLog(value = "根据id拒绝调度:bike_dispatch")
    @PutMapping("rejectDispatchById")
    public CommonResult rejectDispatchById(@RequestBody BikeDispatchHandleVo bikeDispatchHandleVo)
    {
        return bikeDispatchService.rejectDispatchById(bikeDispatchHandleVo);
    }

    /**
     * 根据用户名获取调度列表
     * @param nickName
     * @return
     */
    @OperationLog(value = "根据用户名获取调度列表:bike_dispatch")
    @GetMapping("getDispatchListByNickName")
    public CommonResult getDispatchListByNickName(@RequestParam("nickName") String nickName)
    {
        return bikeDispatchService.getDispatchListByNickName(nickName);
    }
}
